package br.com.etico.entity.uml;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;


@Entity
@Table(name = "endereco")
//@SequenceGenerator(name = "endereco_id_seq", sequenceName = "endereco_id_seq")
public class Endereco implements Serializable {

	/**
	 * @uml.property  name="id"
	 */
	@Id
//	@GeneratedValue(strategy = GenerationType.AUTO, generator = "endereco_id_seq")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;

	/**
	 * Getter of the property <tt>id</tt>
	 * @return  Returns the id.
	 * @uml.property  name="id"
	 */
	public long getId() {
		return id;
	}

	/**
	 * Setter of the property <tt>id</tt>
	 * @param id  The id to set.
	 * @uml.property  name="id"
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @uml.property  name="rua"
	 */
	@Column(name="rua", length=60)
	private String rua;

	/**
	 * Getter of the property <tt>rua</tt>
	 * @return  Returns the rua.
	 * @uml.property  name="rua"
	 */
	public String getRua() {
		return rua;
	}

	/**
	 * Setter of the property <tt>rua</tt>
	 * @param rua  The rua to set.
	 * @uml.property  name="rua"
	 */
	public void setRua(String rua) {
		this.rua = rua;
	}

	/**
	 * @uml.property  name="numero"
	 */
	@Column(name="numero", length=10)
	private String numero;

	/**
	 * Getter of the property <tt>numero</tt>
	 * @return  Returns the numero.
	 * @uml.property  name="numero"
	 */
	public String getNumero() {
		return numero;
	}

	/**
	 * Setter of the property <tt>numero</tt>
	 * @param numero  The numero to set.
	 * @uml.property  name="numero"
	 */
	public void setNumero(String numero) {
		this.numero = numero;
	}
	
	public Cliente getCliente() {
		return cliente;
	}

	public void setCliente(Cliente cliente) {
		this.cliente = cliente;
	}
	
	@Fetch(FetchMode.SELECT)
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade(CascadeType.SAVE_UPDATE)
	@JoinColumn(name="id_cliente", nullable=false, insertable=true,updatable=true)
	private Cliente cliente;

}
